CREATE TABLE [dbo].[DnnProduct_DesktopModulePermission]
(
[DesktopModulePermissionID] [int] NOT NULL IDENTITY(1, 1),
[PortalDesktopModuleID] [int] NOT NULL,
[PermissionID] [int] NOT NULL,
[AllowAccess] [bit] NOT NULL,
[RoleID] [int] NULL,
[UserID] [int] NULL,
[CreatedByUserID] [int] NULL,
[CreatedOnDate] [datetime] NULL,
[LastModifiedByUserID] [int] NULL,
[LastModifiedOnDate] [datetime] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[DnnProduct_DesktopModulePermission] ADD CONSTRAINT [PK_DnnProduct_DesktopModulePermission] PRIMARY KEY CLUSTERED  ([DesktopModulePermissionID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[DnnProduct_DesktopModulePermission] ADD CONSTRAINT [IX_DnnProduct_DesktopModulePermission] UNIQUE NONCLUSTERED  ([PortalDesktopModuleID], [PermissionID], [RoleID], [UserID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[DnnProduct_DesktopModulePermission] ADD CONSTRAINT [FK_DnnProduct_DesktopModulePermission_DnnProduct_Permission] FOREIGN KEY ([PermissionID]) REFERENCES [dbo].[DnnProduct_Permission] ([PermissionID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[DnnProduct_DesktopModulePermission] ADD CONSTRAINT [FK_DnnProduct_DesktopModulePermission_DnnProduct_PortalDesktopModules] FOREIGN KEY ([PortalDesktopModuleID]) REFERENCES [dbo].[DnnProduct_PortalDesktopModules] ([PortalDesktopModuleID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[DnnProduct_DesktopModulePermission] ADD CONSTRAINT [FK_DnnProduct_DesktopModulePermissionDnnProduct_Users] FOREIGN KEY ([UserID]) REFERENCES [dbo].[DnnProduct_Users] ([UserID])
GO
